// Package svc
// @Author zhongxc
// @Date 2024/7/2 16:40:00
// @Desc
package svc

import (
	"go.uber.org/zap"
	"vben-admin/config"
	"vben-admin/pkg/database"
	"vben-admin/pkg/hook"
	"vben-common/msdb"
	"vben-common/utils"
)

type ServiceContext struct {
	Config *config.Config
	Db     *msdb.MsDB
	ZapLog *zap.Logger // 日志指针
}

func NewServiceContext(cnf *config.Config) *ServiceContext {
	/*logCnf := &utils.LogConfig{
		AppMode:       cnf.AppMode,
		TimePrecision: cnf.LogConfig.TimePrecision,
		MaxSize:       int(cnf.LogConfig.MaxSize),
		MaxBackups:    int(cnf.LogConfig.MaxBackups),
		MaxAge:        int(cnf.LogConfig.MaxAge),
		Compress:      cnf.LogConfig.Compress,
		TextFormat:    cnf.LogConfig.TextFormat,
		BasePath:      cnf.BasePath,
		LogFileName:   cnf.LogConfig.GoSkeletonLogName,
	}*/
	return &ServiceContext{
		Config: cnf,
		Db:     database.ConnMysql(cnf.MysqlConfig.Dsn),
		ZapLog: utils.CreateZapFactory(hook.ZapLogHandler, cnf.ZapLogConfig),
	}
}
